import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patheffects as pe

# 生成正弦函数曲线的 x 和 y 坐标数组
x = np.linspace(0, 8*np.pi, 1000)
y = np.sin(x)

# 设置图形的尺寸和背景色
fig, ax = plt.subplots(figsize=(8, 6))
fig.patch.set_facecolor('#f2f2f2')
ax.set_facecolor('#f2f2f2')

# 绘制正弦函数曲线，线条宽度为 3，颜色为彩虹色
ax.plot(x, y, lw=3,
        color=[(1, 0, 0), (1, 0.5, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (0.29, 0, 0.51)], 
        path_effects=[pe.withStroke(linewidth=5, foreground="white")])

# 设置图形的标题和坐标轴标签
ax.set_title('A Rainbow Sine Wave', fontsize=20, fontweight='bold')
ax.set_xlabel('x', fontsize=16)
ax.set_ylabel('y', fontsize=16)

# 隐藏坐标轴上的刻度、格线和边框
for spine in ['top', 'bottom', 'left', 'right']:
    ax.spines[spine].set_visible(False)
ax.tick_params(axis='both', which='both', length=0)

plt.show()
